#!/usr/bin/perl -wT

require 5.001;
use strict;
use CGI;

umask 002;

my $input = new CGI;

# sanity checks
my $sane = 1;
# list name could be tighter: only lowercase or only existing list
$sane &&= ($input->param('listname') =~ /^[0-9a-z\-]+$/);
$sane &&= ($input->param('date') =~ /^\d{4}\/(\d{2})?$/);
$sane &&= ($input->param('msg') =~ /^msg\d+\.html$/);

my $message;
my $title;

if ($sane) {
    # log all connections that present sane input
    my $logfile = '/org/lists.debian.org/spam-log/spam-report.log';
    open (LOG, ">>$logfile") ;
    my $time = time;
    print LOG "time: $time; ";
    #if (exists $ENV{'REMOTE_HOST'}) {
    #  print LOG "host: $ENV{'REMOTE_HOST'}; addr: $ENV{'REMOTE_ADDR'} sub_cnt: $#subscribe unsub_cnt: $#unsubscribe: email: $user_email\n";
    #} else {
    print LOG "addr: $ENV{'REMOTE_ADDR'}; list: ".$input->param('listname').", date: ".$input->param('date').", msg: ".$input->param('msg')."\n";
    #}
    close LOG;
    $message = <<SUCCESS
<h2>Report accepted</h2>
<p>
Thank you for reporting this email as a potential spam message. Scores are reviewed regularly, and are used to mark emails as spam.
</p>
SUCCESS
;
    $title = 'Email status recorded';
}
else {
    $message = <<ERRMSG
<h2>An error occurred</h2>
<p>
Unfortunately, your report could not be recorded. Please try again or contact the listmasters.
</p>
ERRMSG
;
}
print $input->header;
print $input->start_html(-title=>$title, -style=>{ -src => ['/debian.css','/debian-en.css']});
print <<BLAH
<div id="header">
   <div id="upperheader">
   <div id="logo">
  <a href="/"><img src="/Pics/openlogo-50.png" width="50" height="61" alt=""></a>
  </div> <!-- end logo -->
</div> <!-- end upperheader -->
<!--UdmComment-->
<div id="navbar">
<p class="hidecss"><a href="#inner">Skip Quicknav</a></p>
<ul>
   <li><a href="http://www.debian.org/intro/about">About Debian</a></li>
   <li><a href="http://www.debian.org/distrib/">Getting Debian</a></li>
   <li><a href="http://www.debian.org/support">Support</a></li>
   <li><a href="http://www.debian.org/devel/">Developers'&nbsp;Corner</a></li>
</ul>
</div> <!-- end navbar -->
<p id="breadcrumbs"><a href="/">mailing lists </a>/ Spam Report accepted </p>
</div> <!-- end header -->

<div id="content">
	<div class="index_include">


$message
<p><hr noshade width="100%" size="1">

Back to:
<a href="http://www.debian.org/">Debian Project homepage</a> ||

<a href="/">Debian mailing lists</a>

<hr noshade width="100%" size="1">

<p><small>You may <a href="http://www.debian.org/Bugs/Reporting">submit bugs</a>
against the list archives using the
<a href="http://bugs.debian.org/listarchives"><var>listarchives</var>
pseudo-package</a> or contact the maintainer at
<a href="mailto:listarchives\@debian.org">listarchives\@debian.org</a>.
The scripts which generate the archives are
<a href="http://packages.debian.org/unstable/web/lists-archives.html">available</a>

under the GPL.</small></p>

<p><small>See the Debian <a href="http://www.debian.org/contact">contact
page</a> for further information on contacting us.</small></p>
</div>
</div>
BLAH
;
print $input->end_html;
exit 0;
